package com.shanghai.shanghaielectric.UI.DilaogView;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.shanghai.shanghaielectric.MyApplication;
import com.shanghai.shanghaielectric.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * Created by Administrator on 2017/9/2 0002.
 */

public class Dialog_Alert extends DialogFragment {


    public interface DialogAlertListener {
        void onClink(boolean flag);
    }
    private static DialogAlertListener mDialogAlertListener;

    public static void   setDiolgAlertListener(DialogAlertListener dialogAlertListener){
        mDialogAlertListener = dialogAlertListener;
    }
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.bt_cancel)
    Button btCancel;
    @BindView(R.id.bt_certain)
    Button btCertain;

    @OnClick({R.id.bt_cancel, R.id.bt_certain})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_cancel:
                mDialogAlertListener.onClink(false);
                dismiss();
                break;
            case R.id.bt_certain:
                mDialogAlertListener.onClink(true);

                dismiss();
                break;
        }
    }

    public Context mContext;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.m_dialog, container);
        ButterKnife.bind(this, view);

//        Toast.makeText(mContext, this.getTag().toString(), Toast.LENGTH_SHORT).show();
        initView();
        initData();
        return view;
    }

    private void initView() {

            tvContent.setText(commandName);

    }


    public String commandName;
    public void setCommandName(String name) {
        this.commandName = name;
    }
    private void initData() {
        mContext = MyApplication.getContext();
    }


}
